--Function of adding new integer column
create or replace procedure meta_add_int_column(
    --Table id
    a_table_id raw,
    --Column id
    a_column_id raw,
    --Column name
    a_column_name varchar2)
as
    --Table name
    a_table_name varchar2(26);
begin
    p_check_col_not_exists(a_table_id, a_column_id, a_column_name);

    a_table_name :=  p_get_table_name(a_table_id);
    
    --Changing the metadata
    insert into meta_int_columns(column_id, table_id, column_name,
        order_index, customization_level)
    values (a_column_id, a_table_id, a_column_name,
        p_generate_order_index(a_table_id), 1);
        
    --Dropping table view
    p_drop_view_if_exists(a_table_name);
         
    execute immediate 'alter table tbl_' 
    || a_table_name
    || ' add ' || a_column_name
    || ' number(10)';
         
    --Creating table view
    p_create_table_view(a_table_id);

end;

--go

--Function of setting column default value
create or replace procedure meta_set_int_default(
    --Column id
    a_column_id raw,
    --Default value
    a_default_value number)
as
    --Table id
    a_table_id raw(16);
    --Table name
    a_table_name varchar2(26);
    --Column name
    a_column_name varchar2(26);
    --Column type
    a_column_type varchar2(30);
begin
    p_check_col_type(a_column_id, 'meta_int_columns', 'int');
    
    p_set_numeric_default(a_column_id, a_default_value);
end;

--go

--Function of setting int column maximum
create or replace procedure meta_set_int_maximum(
    --Column id
    a_column_id raw,
    --Maximum
    a_maximum number)
as
begin
    p_check_col_type(a_column_id, 'meta_int_columns', 'int');
    
    p_set_numeric_maximum(a_column_id, a_maximum);
end;

--go

--Function of setting int column minimum
create or replace procedure meta_set_int_minimum(
    --Column id
    a_column_id raw,
    --Minimum
    a_minimum number)
as
begin
    p_check_col_type(a_column_id, 'meta_int_columns', 'int');
    
    p_set_numeric_minimum(a_column_id, a_minimum);
end;

--go